package com.bjpowerndoe.ylb.web.controller;

import com.bjpowerndoe.ylb.web.model.CommonResult;
import com.bjpowerndoe.ylb.web.model.dto.AppInfoDTO;
import com.bjpowerndoe.ylb.web.model.vo.AppInfoVO;
import com.bjpowerndoe.ylb.web.service.inter.MangerService;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "盈利宝平台功能")
@RestController
@RequiredArgsConstructor
public class ManagerController {

    /** 获取页面三项数据：注册用户数量,累计成交金额,利率平均值*/

    private final MangerService mangerService;

    @ApiOperation(value = "平台三项数据",notes = "总注册用书数量,累计成交金额,利率平均值")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",value = "用户姓名",dataType = "String",required = true,defaultValue = "lisi"),
            @ApiImplicitParam(name = "age",value = "用户年龄",dataType = "int",required = true,defaultValue = "10")
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功",response = CommonResult.class),
            @ApiResponse(code = 404,message = "请求url不存在")
    })
    @GetMapping("/app/info")
    public CommonResult getAppBaseInfo(String name,Integer age){

        AppInfoDTO appBaseDTO = mangerService.getAppBaseInfo();

        //DTO-VO
        AppInfoVO appInfoVO = new AppInfoVO();
        appInfoVO.setUserCount(appBaseDTO.getRegisterUserCount());
        appInfoVO.setAvgProductRate(appBaseDTO.getAvgRate());
        appInfoVO.setAllBidMoney(appBaseDTO.getSumBidMoney());

        return CommonResult.ok(appInfoVO);
    }
}
